package com.curd.jpa.base.service.impl.jpapackaging;

import org.springframework.data.domain.Example;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import java.util.Collection;
import java.util.List;
import java.util.Optional;

public interface PackagingService<DOMAIN, ID> {
    List<DOMAIN> findAll();

    Page<DOMAIN> findAll(Pageable var1);

    List<DOMAIN> findAll(Sort var1);

    List<DOMAIN> findAllById(Iterable<ID> var1);

    <S extends DOMAIN> List<S> saveAll(Iterable<S> var1);

    void flush();

    <S extends DOMAIN> S saveAndFlush(S var1);

    void deleteInBatch(Iterable<DOMAIN> var1);

    void deleteAllInBatch();

    /**
     * getOne 不建议使用
     * @param var1
     * @param <S>
     * @return
     */
//    DOMAIN getOne(ID var1);

    <S extends DOMAIN> List<S> findAll(Example<S> var1);

    <S extends DOMAIN> List<S> findAll(Example<S> var1, Sort var2);

    Optional<DOMAIN> findOne(Specification<DOMAIN> var1);

    List<DOMAIN> findAll(Specification<DOMAIN> var1);

    Page<DOMAIN> findAll(Specification<DOMAIN> var1, Pageable var2);

    List<DOMAIN> findAll(Specification<DOMAIN> var1, Sort var2);

    long count(Specification<DOMAIN> var1);

    List<DOMAIN> findAllByIdIn(Collection<ID> ids, Sort sort);

    Page<DOMAIN> findAllByIdIn(Collection<ID> ids, Pageable pageable);

    DOMAIN findAllByIdIn(Collection<ID> id);

    long deleteByIdIn(Collection<ID> ids);
}
